<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="车号" prop="chehao">
        <el-input v-model="queryParams.chehao" placeholder="请输入车号 " clearable @keyup.enter.native="handleQuery" />
      </el-form-item>



      <el-form-item label="称重编号" prop="czbh">
        <el-input v-model="queryParams.xcbm" placeholder="请输入称重编号 " clearable @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item label="卡号" prop="card_id">
        <el-input v-model="queryParams.xcbm" placeholder="请输入订单编号 " clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
<<<<<<< HEAD
          v-hasPermi="['system:merge:list']">首次录入信息</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" :disabled="single" size="mini" @click="handleAdd"
          v-hasPermi="['system:merge:list']">非首次录入</el-button>
=======
          v-hasPermi="['system:guozhong:edit']">首次录入信息</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" :disabled="single" size="mini" @click="handleAdd"
          v-hasPermi="['system:guozhong:add']">非首次录入</el-button>
>>>>>>> b4a0e2dba4b1f1e0b05e6d155df4272830d06f27
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="guozhongList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" align="center" />
      <!-- <el-table-column label=" " width="55" align="center" prop="gid" /> -->
      <el-table-column label="订单编号" width="200" align="center" prop="ddbh" />
      <el-table-column label="称重编号" width="200" align="center" prop="czbh" />
      <el-table-column label="卡号" width="200" align="center" prop="card_id" />
      <el-table-column label="车号" width="150" align="center" prop="chehao" />
      <el-table-column label="物料名" width="200" align="center" prop="wlmc" />
      <el-table-column label="进厂时间" align="center" prop="mzsj" />
      <el-table-column label="出厂时间" align="center" prop="pzsj" />
      <el-table-column label="进厂地磅" align="center" prop="dbh" />
      <el-table-column label="过磅状态" align="center" prop="gbzt" />
      <el-table-column label="内外销" align="center" prop="sd_dwx" />
      <el-table-column label="包装物名" align="center" prop="sd_bzwmc" />
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改tb对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-row :guiger="40">
          <el-col :span="6">
            <el-form-item label="带出车号" prop="chehao">
              <el-input v-model="form.chehao" placeholder="请输入 " readonly />
            </el-form-item>
            <el-form-item label="客户编号" prop="sdfbh" readonly>
              <el-input v-model="form.sdfbh" readonly />
            </el-form-item>
            <el-form-item label="客户名称" prop="shoudf" readonly>
              <el-input v-model="form.shoudf" readonly />
            </el-form-item>
            <el-form-item label="公司编号" prop="gsbh" readonly>
              <el-input v-model="form.gsbh" readonly />
            </el-form-item>
            <el-form-item label="公司名称" prop="gsmc" readonly>
              <el-input v-model="form.gsmc" readonly />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="物料编号" prop="wlbh" readonly>
              <el-input v-model="form.wlbh" readonly />
            </el-form-item>
            <el-form-item label="仓库编号" prop="ckbh" readonly>
              <el-input v-model="form.ckbh" readonly />
            </el-form-item>
            <el-form-item label="仓库名称" prop="ckmc" readonly>
              <el-input v-model="form.ckmc" readonly />
            </el-form-item>
            <el-form-item label="物料名称" prop="wlmc" readonly>
              <el-input v-model="form.wlmc" readonly />
            </el-form-item>
            <el-form-item label="送达方" prop="songdf">
              <el-input v-model="form.songdf" readonly />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="送达方编号" prop="khbh" readonly>
              <el-input v-model="form.khbh" readonly />
            </el-form-item>
            <el-form-item label="过磅类型" prop="gblx" readonly>
              <el-input v-model="form.gblx" readonly />
            </el-form-item>
            <el-form-item label="交货单号" prop="ddbh" readonly>
              <el-input v-model="form.ddbh" readonly />
            </el-form-item>
            <el-form-item label="预置重量" prop="yzzl" readonly>
              <el-input v-model="form.yzzl" readonly />
            </el-form-item>
            <el-form-item label="预发吨位" prop="ddwlsl" readonly>
              <el-input v-model="form.ddwlsl" readonly />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="包装样式" prop="sd_bzwmc" readonly>
              <el-input v-model="form.sd_bzwmc" readonly />
            </el-form-item>
            <el-form-item label="预置扣重" prop="yzkz" readonly>
              <el-input v-model="form.yzkz" readonly />
            </el-form-item>
            <el-form-item label="内销外销" prop="sd_dwx" readonly>
              <el-input v-model="form.sd_dwx" readonly />
            </el-form-item>
            <el-form-item label="进厂地磅" prop="dbh">
              <el-input v-model="form.bh" readonly />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="车号" prop="chehaomm">
              <el-input v-model="form.chehaomm" placeholder="请输入 " />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="手机号" prop="shoujihao" v-if="isShouji">
              <el-input v-model="form.shoujihao" placeholder="请输入 " />
            </el-form-item>
            <el-form-item label="二维码（卡号）" prop="shoujihao" v-if="isKahao">
              <el-input v-model="form.shoujihao" placeholder="请输入 " />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listGuozhong, getGuozhong, delGuozhong, addGuozhong, updateGuozhong } from "@/api/system/Fdongbei/MMguozhong";
import { listMergeGuozhong, addMerge, updateMerge } from "@/api/system/Fdongbei/merge";
export default {
  name: "Guozhong",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件;
      showSearch: true,
      isShouji: true,
      isKahao: false,
      // 总条数
      total: 0,
      // tb表格数据
      guozhongList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        gid: null,
        ddbh: null,
        card_id: null,
        chehao: null,
        wlmcc: null,
        gysbh: null,
        gysdm: null,
        gsmc: null,
        gsbh: null,
        wlbh: null,
        wlmc: null,
        ckbh: null,
        ckmc: null,
        khbh: null,
        songdf: null,
        sdfbh: null,
        shoudf: null,
        jhxm: null,
        mz: null,
        mzsj: null,
        pz: null,
        pzsj: null,
        jz: null,
        hykz: null,
        hyjfkx: null,
        yzkz: null,
        jszl: null,
        yzzl: null,
        jsdj: null,
        jsje: null,
        jlscbz: null,
        yhckrxm: null,
        yhkh: null,
        lxdh: null,
        fpbh: null,
        fpshr: null,
        fpscxxlrsj: null,
        fpscsfzh: null,
        fpsccgbz: null,
        gblx: null,
        gbzt: null,
        hytb: null,
        sgtm: null,
        sby: null,
        xhry: null,
        yj: null,
        tplj: null,
        ddxmbh: null,
        zczm: null,
        zczmtp: null,
        shsfzh: null,
        ddlx: null,
        zcks: null,
        zcmz: null,
        sjxm: null,
        sjdh: null,
        sjsfz: null,
        ymqybsm: null,
        ymqysj: null,
        ymsbm: null,
        ymsbmdy: null,
        xcp: null,
        xcpdy: null,
        zcp: null,
        zcpdy: null,
        hyd: null,
        hyddy: null,
        cmz: null,
        cmzdy: null,
        xcbm: null,
        zjshbs: null,
        shfpbh: null,
        shfpbhdy: null,
        ddwlsl: null,
        rkgbd: null,
        rkgbddy: null,
        ckgbd: null,
        ckgbddy: null,
        ddysdh: null,
        ddyszl: null,
        dbh: null,
        dbh2: null,
        czymc: null,
        czymc2: null,
        nlmtbz1: null,
        nlmtbz2: null,
        qyry: null,
        jlscsbcs: null,
        jshth: null,
        fpscsbcs: null,
        fpscfhwb: null,
        orclgl: null,
        hysqgch: null,
        ddbdcs: null,
        guige: null,
        sapbzsc: null,
        fzfs: null,
        zds: null,
        zzysdw: null,
        yfrq: null,
        yfk: null,
        bzxx: null,
        dzymkz: null,
        yslx: null,
        cckz: null,
        dzymkdz: null,
        ershisibz: null,
        ycJzcc: null,
        ycCcc: null,
        jctuCp: null,
        jctuHk: null,
        cctuCp: null,
        cctuHk: null,
        bz: null,
        czqztc: null,
        lscp: null,
        lscpBj: null,
        ddysmz: null,
        ddysjz: null,
        ysjzBj: null,
        fkZdr: null,
        sdDwx: null,
        sdBzwmc: null,
        fwZdz: null,
        fwZgz: null,
        fwNwx: null,
        fwBzwm: null,
        kkRjbb: null,
        gbRjbb: null,
        fksj: null,
        clFbbz: null,
        htYcclYcKg: null,
        ysmzBj: null,
        upsapbs: null,
        kksj: null,
        zzmtbs: null,
        thirdCompany: null,
        photoSfz: null,
        yhzhsfzh: null,
        fpph: null,
        hzddybs: null,
        chexc: null,
        zhuanchangbiaoji: null,
        zhuanchangcishu: null,
        photoCkqr: null,
        photoZxcqr: null,
        qymc: null,
        khyh: null,
        yshdwmc: null,
        zzjgdm: null,
        sllx: null,
        photoWtxy: null,
        photoZczm: null,
        photoCbtdht: null,
        photoZt: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        gid: [
          { required: true, message: " 不能为空", trigger: "blur" }
        ],
        czbh: [
          { required: true, message: " 不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询tb列表 */
    getList() {
      this.loading = true;
<<<<<<< HEAD

=======
>>>>>>> b4a0e2dba4b1f1e0b05e6d155df4272830d06f27
      listMergeGuozhong(this.queryParams).then(response => {
        this.guozhongList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.isShouji = true;
      this.isKahao = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        gid: null,
        czbh: null,
        ddbh: null,
        card_id: null,
        chehao: null,
        wlmcc: null,
        gysbh: null,
        gysdm: null,
        gsmc: null,
        gsbh: null,
        wlbh: null,
        wlmc: null,
        ckbh: null,
        ckmc: null,
        khbh: null,
        songdf: null,
        sdfbh: null,
        shoudf: null,
        jhxm: null,
        mz: null,
        mzsj: null,
        pz: null,
        pzsj: null,
        jz: null,
        hykz: null,
        hyjfkx: null,
        yzkz: null,
        jszl: null,
        yzzl: null,
        jsdj: null,
        jsje: null,
        jlscbz: null,
        yhckrxm: null,
        yhkh: null,
        lxdh: null,
        fpbh: null,
        fpshr: null,
        fpscxxlrsj: null,
        fpscsfzh: null,
        fpsccgbz: null,
        gblx: null,
        gbzt: null,
        hytb: null,
        sgtm: null,
        sby: null,
        xhry: null,
        yj: null,
        tplj: null,
        ddxmbh: null,
        zczm: null,
        zczmtp: null,
        shsfzh: null,
        ddlx: null,
        zcks: null,
        zcmz: null,
        sjxm: null,
        sjdh: null,
        sjsfz: null,
        ymqybsm: null,
        ymqysj: null,
        ymsbm: null,
        ymsbmdy: null,
        xcp: null,
        xcpdy: null,
        zcp: null,
        zcpdy: null,
        hyd: null,
        hyddy: null,
        cmz: null,
        cmzdy: null,
        xcbm: null,
        zjshbs: null,
        shfpbh: null,
        shfpbhdy: null,
        ddwlsl: null,
        rkgbd: null,
        rkgbddy: null,
        ckgbd: null,
        ckgbddy: null,
        ddysdh: null,
        ddyszl: null,
        dbh: null,
        dbh2: null,
        czymc: null,
        czymc2: null,
        nlmtbz1: null,
        nlmtbz2: null,
        qyry: null,
        jlscsbcs: null,
        jshth: null,
        fpscsbcs: null,
        fpscfhwb: null,
        orclgl: null,
        hysqgch: null,
        ddbdcs: null,
        guige: null,
        sapbzsc: null,
        fzfs: null,
        zds: null,
        zzysdw: null,
        yfrq: null,
        yfk: null,
        bzxx: null,
        dzymkz: null,
        yslx: null,
        cckz: null,
        dzymkdz: null,
        ershisibz: null,
        ycJzcc: null,
        ycCcc: null,
        jctuCp: null,
        jctuHk: null,
        cctuCp: null,
        cctuHk: null,
        bz: null,
        czqztc: null,
        lscp: null,
        lscpBj: null,
        ddysmz: null,
        ddysjz: null,
        ysjzBj: null,
        fkZdr: null,
        sdDwx: null,
        sdBzwmc: null,
        fwZdz: null,
        fwZgz: null,
        fwNwx: null,
        fwBzwm: null,
        kkRjbb: null,
        gbRjbb: null,
        fksj: null,
        clFbbz: null,
        htYcclYcKg: null,
        ysmzBj: null,
        upsapbs: null,
        kksj: null,
        zzmtbs: null,
        thirdCompany: null,
        photoSfz: null,
        yhzhsfzh: null,
        fpph: null,
        hzddybs: null,
        chexc: null,
        zhuanchangbiaoji: null,
        zhuanchangcishu: null,
        photoCkqr: null,
        photoZxcqr: null,
        qymc: null,
        khyh: null,
        yshdwmc: null,
        zzjgdm: null,
        sllx: null,
        photoWtxy: null,
        photoZczm: null,
        photoCbtdht: null,
        photoZt: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.czbh)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd(row) {
      this.reset();
      const czbh = row.czbh || this.ids
      this.isShouji = false;
      this.isKahao = true;
      getGuozhong(czbh).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "添加tb";
      });

    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const czbh = row.czbh || this.ids
      getGuozhong(czbh).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改tb";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        console.log(this.title + "<------title");
        this.form.chexc = this.$store.state.user.name;
        if (valid) {
          if (this.title == '修改tb') {
            addMerge(this.form).then(response => {
              this.$modal.msgSuccess("首次添加成功！");
              this.open = false;
              this.getList();
            });
          } else {
            updateMerge(this.form).then(response => {
              this.$modal.msgSuccess("添加成功");
              this.isShouji = true;
              this.isKahao = false;
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const czbhs = row.czbh || this.ids;
      this.$modal.confirm('是否确认删除tb编号为"' + czbhs + '"的数据项？').then(function () {
        return delGuozhong(czbhs);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/guozhong/export', {
        ...this.queryParams
      }, `guozhong_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
